package mouseAndKeyAndScroll;

import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.input.ScrollEvent;
import javafx.stage.Stage;
import javafx.scene.layout.*;
import javafx.scene.text.*;

// 鼠标滑轮事件
public class ScrollDemo extends Application { 
	private Pane root = new Pane();
	private Text text;
	
	public static void main(String[] args) {
		Application.launch(args);   
	}
	
	@Override
	public void start(Stage stage) {
		
		text = new Text("JavaFX\nJavaFX");
		text.setStyle("-fx-fill: linear-gradient(to right, #00fffc, #fff600)"); 
		text.setFont(Font.font(20));
		root.getChildren().addAll(text);
		
		Scene scene = new Scene(root, 500, 400);
		stage.setScene(scene);
		stage.show();
		
		// 事件
		root.setOnScroll( (ScrollEvent e) -> {
			double y = e.getDeltaY();
			text.setTranslateY(text.getTranslateY() + y);
		});
	}
}

